#!/bin/bash
## TODO 用于创建工作目录、用户、自启动项

## 定义代码所在目录
CELERY_PROJECT_PATH="/opt/celeryproject"


## 创建程序运行账户
# useradd -M -s /usr/sbin/nologin celery #ubuntu15
useradd -M -s /sbin/nologin celery #centos6.5



## 复制代码到/opt/celeryproject
if [ ! -d CELERY_PROJECT_PATH ]; then
    mkdir -p CELERY_PROJECT_PATH
    chown celery:celery CELERY_PROJECT_PATH
fi


## 复制配置文件
cp etc/default/celery* /etc/init.d/
cp etc/init.d/celery* /etc/init.d/


## 修改权限
chmod 744 /etc/init.d/celeryd
chmod 744 /etc/init.d/celerybeat


## 加入启动项
chkconfig --add celeryd
chkconfig --add celerybeat